package com.wuyan.locationdog.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.FenceBeanContent
import com.arcsoft.commonbase.ext.gone
import com.arcsoft.commonbase.ext.visible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R


class FenceListAdapter(@LayoutRes layoutResId: Int, data: MutableList<FenceBeanContent>?) :
    BaseQuickAdapter<FenceBeanContent, BaseViewHolder>(layoutResId, data) {

    var showCheckBtn: Boolean = false

    override fun convert(holder: BaseViewHolder, item: FenceBeanContent) {
        holder.apply {
            getView<TextView>(R.id.areaName).text = item.areaName
            //区域类型1禁止驶入区域2禁止驶出区域3区域限速4线路分段限速5.路线偏移
            if (item.areaType == 1) {
                getView<TextView>(R.id.areaType).text = "报警类型：进区域报警"
            } else {
                getView<TextView>(R.id.areaType).text = "报警类型：出区域报警"
            }

            val imageView = getView<ImageView>(R.id.ivCheck)
            val btnEdit = getView<View>(R.id.btnEdit)

            if (showCheckBtn) {
                imageView.visible()
                btnEdit.gone()
            } else {
                imageView.gone()
                btnEdit.visible()
            }


            if (item.isSelect) {
                imageView.setImageResource(R.mipmap.alarm_checked)
            } else {
                imageView.setImageResource(R.mipmap.alarm_unchecked)

            }
        }
    }
}


